package com.yohann.designPattern.state;

/**
 * <p>
 * 抽奖活动
 * </p>
 *
 * @author Yohann
 * @since 2021/2/13 17:36
 */
public class RaffleActivity {
    private State state;
    private int count;

    private State noRaffle = new NoRaffle(this);
    private State canRaffle = new CanRaffle(this);
    private State dispense = new Dispense(this);
    private State dispenseOut = new DispenseOut(this);

    public RaffleActivity(int count) {
        this.state = getNoRaffle();
        this.count = count;
    }

    public void deductMoney() {
        state.deductMoney();
    }

    public void raffle() {
        state.raffle();
    }

    public void dispensePrize() {
        state.dispensePrize();
    }

    public void setState(State state) {
        this.state = state;
    }

    public State getState() {
        return state;
    }

    public int getCount() {
        return --count;
    }

    public State getNoRaffle() {
        return noRaffle;
    }

    public State getCanRaffle() {
        return canRaffle;
    }

    public State getDispense() {
        return dispense;
    }

    public State getDispenseOut() {
        return dispenseOut;
    }
}